#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    vector<int> singleNumbers(vector<int>& nums) {
        //使用异或
        int e=0;
        for(int i = 0;i<nums.size();++i){
            e ^=nums[i];
        }
        //寻找e二进制最右边的1
        int T= e&((~e)+1);
        int D= 0;
        for(int i = 0;i<nums.size();++i){
            //把nums中这一位是1的全部提取出来
            if((nums[i]&T)==T){
                D ^= nums[i];
            }
        }
        return {D,e^D};
    }
};

int main(){
    Solution S;
    vector<int> nums = {1,2,5,2};
    vector<int> result = S.singleNumbers(nums);
    return 0;
}
